package main

import (
	"fmt"
	"log"

	"github.com/spf13/viper"
)

var Program = "agentd"

func loadConfig() {
	viper.SetConfigName(fmt.Sprintf(".%s", Program)) // name of config file (without extension)

	viper.AddConfigPath("$HOME") // path to look for the config file in
	viper.AddConfigPath(".")     // optionally look for config in the working directory

	if err := viper.ReadInConfig(); err != nil {
		if _, ok := err.(viper.ConfigFileNotFoundError); ok {
			// Config file not found; ignore error if desired
		} else {
			// Config file was found but another error was produced
			log.Printf("error reading config file: %v", err)
		}
	}
}

func main() {
	loadConfig()
	Execute()
}
